<template>
  <div class="box">
    <div class="block">
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in activities"
          :key="index"
          :icon="activity.icon"
          :type="activity.type"
          :color="activity.color"
          :size="activity.size"
          :timestamp="activity.timestamp"
        >
          {{ activity.content }}
        </el-timeline-item>
      </el-timeline>
    </div>
    <div class="chart">
      <div class="inner">
        <a-card class="box1" title="死亡人数" :bordered="false" :loading="loading">
          <casualty class="data1"></casualty>
        </a-card>
        <a-card class="box1" title="受伤人数" :bordered="false" :loading="loading">
          <emperson class="data1"></emperson>
        </a-card>
      </div>
      <div class="inner">
          <a-card class="box1" title="距事故发生报案时间" :bordered="false" :loading="loading">
            <div class="time">{{ time }} 分钟</div>
          </a-card>
          <a-card class="box1" title="损失估计" :bordered="false" :loading="loading">
            <cost style="margin-top: -60px; margin-left: 10px;" ></cost>
          </a-card>
      </div>

    </div>
  </div>
</template>

<script>
import datapanel from "./components/datapanel.vue";
import casualty from "./components/casualty.vue";
import emperson from './components/emperson.vue';
import cost from "./components/cost.vue"
import {getTimeline} from "@/api/accidentReplay/accidentReplay"
export default {
  components:{
    datapanel,
    casualty,
    emperson,
    cost,
  },
  data() {
    return {
      activities: [],
      time:30
    };
  },
  beforeCreate() {
    this.$nextTick(() => {
      document.body.setAttribute("style", "background:#f0f2f5");
    });
  },
  //实例销毁之前钩子--移除body 标签的属性style
  beforeDestroy() {
    document.body.removeAttribute("style");
  },
  mounted(){
    getTimeline().then((res)=>{
      console.log(res);
      if(res.code == 200){
        this.activities = res.data;
      }
    })
  }
};
</script>
<style>
.box {
  /* margin: 10px 10px; */
  display: flex;
}
.block {
    width: 500px;
    height: 820px;
    background-color: #ffffff;
    overflow:scroll;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 20px;
    margin:10px 20px 0 10px;
}
.box1{
  margin: 10px;
  width: 560px;
  height: 400px;
}
.chart{
  display: flex;
  flex-direction: column;
}
.inner{
  /* margin: 20px; */
  display: flex;
}
.data1{
  margin-top: -70px;
}
.time{
  font-size: 40px;
  font-weight: bold;
  margin: 100px 180px;
}
</style>